package com.frxuexi.mynews.activity

import android.os.Bundle
import android.text.Html
import android.view.LayoutInflater
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.arouter.launcher.ARouter
import com.frxuexi.mynews.R
import com.tencent.mmkv.MMKV
import com.umeng.message.PushAgent


class SplashActivity : AppCompatActivity() {
    lateinit var dialog: AlertDialog
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)
        PushAgent.getInstance(this).onAppStart();
        val mmkv = MMKV.defaultMMKV()


        val view = LayoutInflater.from(this).inflate(R.layout.dialog_welcome, null)
        val tv = view.findViewById<TextView>(R.id.wel_con)
        val htmlString = "这是一段隐私政策描述，其中包含<font color='#0000FF'>隐私政策</font>"
        tv.setText(Html.fromHtml(htmlString))
        view.findViewById<TextView>(R.id.wel_con)
            .setOnClickListener {

            }

        view.findViewById<TextView>(R.id.wel_agree)
            .setOnClickListener {
                ARouter.getInstance().build("/app/MainActivity").navigation()
                finish()
            }

        view.findViewById<TextView>(R.id.wel_noagree)
            .setOnClickListener {
                dialog.dismiss()
            }
        if(!mmkv.decodeBool("first",false)) {
            mmkv.encode("first",true)
            dialog = AlertDialog.Builder(this)
                .setView(view)
                .create()
            dialog.show()
        }else{
            ARouter.getInstance().build("/app/MainActivity").navigation()
            finish()
        }
    }
}